<template>
    <div>
   <h1>显示页面</h1>
    </div>
    <a href="http://localhost:5183/api/StareRong/ExPort">模拟导出Excel示lie一行一列</a>

    房号:
    <input type="text" v-model="yte.name">
    房型
     <select v-model="yte.stareID">
                        <option value="-1">==请选择房型==</option>
                        <option v-for="a in obj":value="a.stareID">{{a.stareName}}</option>
                    </select>

       <input type="button" value="查询" @click="selets()">
       
    <table class="table">
        <thead>
             <tr>
                <td>房号</td>
                <td>时间</td>
                <td>手机号</td>
                <td>姓名</td>
                <td>图片</td>
                <td>地址</td>
                <td>房型</td> 
                <td>状态</td>
                <td>操作</td>
             </tr>
        </thead>
           <tbody>
             <tr v-for="k in data">
                <td>{{k.stareRongName}}</td>
                <td>{{k.stareRongTime}}</td>
                <td>{{k.phone}}</td>
                <td>{{k.name}}</td>
                <td><img style="height:60px;width:60px;" :src="axios.defaults.baseURL+k.stareRongImg"></td>
                <td>{{k.adds}}</td>
                <td>{{k.stareName}}</td>
                 <td>{{k.isdelete?"开启":"关闭"}}</td>
                <td>
                  <input type="button" value="修改状态" @click="updat(k.stareRongId)">
                  <input type="button" value="批量修改状态" @click="pupdat(k.stareRongId)">
                </td>
             </tr>
        </tbody>
    </table>

      <input type="button" :value="d" v-for="d in yte.mumber" @click="yyt(d)">
      
       一共{{yte.count}}条,每页显示{{yte.size}}条，一共第{{yte.mumber}}页,单前{{yte.index}}页
    <input type="button" value="首页" @click="pangdex(1)">
      <input type="button" value="上一页" @click="pangdex(2)">

       <input type="button" value="下一页" @click="pangdex(3)">
        <input type="button" value="尾页" @click="pangdex(4)">

         <input type="number" v-model="yte.index" style="width: 30px;height: 30px;"><input type="button" value="跳转" @click="sk">

          <select v-model="yte.size" @change="pangn()">
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
            </select>    
            
</template>


<script setup lang="ts">
import { RefSymbol } from '@vue/reactivity';
import axios from 'axios';
 import {ref,onMounted} from 'vue';
  import {useRouter} from 'vue-router';
 const router=useRouter();

  onMounted(()=>{
    GetStares();
    Show();
  })

   const yyt=(val:number)=>{
   yte.value.index=val;
    Show();

   }

   const updat=(id:number)=>{

       axios.delete("http://localhost:5183/api/StareRong/LogIceDeketeMember",{params:{stareRongId:id}}).then(res=>{

            if(res.data>0){

           alert("修改状态成功")
         Show();

            }else{

                alert("修改状态失败")
            }
       })
   }

   const GetStares=()=>{
    axios.get("http://localhost:5183/api/Stare/GetStares").then(res=>{

          obj.value=res.data

    })

   }

   const obj=ref({

      "stareID": 0,
      "stareName": "",

   })


  const selets=()=>{

    Show();

  }


    const pangn=()=>{
     Show();
     }

      const sk=()=>{
      if(yte.value.index<1||yte.value.index<yte.value.mumber){
      alert("无效");
       yte.value.index=1;

        }
      Show();

     }

     const pangdex=(val:any)=>{
     if(val==1){
        yte.value.index=1;
        Show();
     }
    if(val==2&&yte.value.index>1){
             yte.value.index--;
             Show();
        }

       if(val==3&&yte.value.index<yte.value.mumber){
              yte.value.index++;
              Show()
       }

         if(val==4){
              yte.value.index=yte.value.mumber
              Show();
              
       }
    }



  const yte=ref({

     name:'',
     stareID:-1,
     index:1,//页数
     size:2,//条数

     count:0,//总条数
     mumber:0,//总页数

  })

  
   

  
  
 const data=ref([{
  "stareID": 1,
      "stareRongName": "qq",
      "name": "就是",
      "adds": "南昌市",
      "phone": "21212121212",
      "stareRongImg": "/pic/2e77bf7a-0959-4a4d-a4bf-c68293b368a84.jpg",
      "stareRongTime": "2025-06-12T00:00:00",
      "stareName": "三室一厅",
      "stareRongId": 8,
      "isdelete": 0


 }])
   
 
  const Show=()=>{

     axios.get("http://localhost:5183/api/StareRong/Show",{params:yte.value}).then(res=>{


     data.value=res.data.mumber;
      yte.value.count=res.data.count;
       yte.value.mumber=Math.ceil(yte.value.count / yte.value.size);

       
     })

  }


</script>

<style scoped>

</style>